<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>数组元素排序</title>
	<script type="text/javascript">

		function paixu (arr) {
			for (var i = 0;i<arr.length;i++) {
				for (var j = 0; j < arr.length-i-1; j++) {
					if (arr[j] < arr[j+1]) {
						var num = arr[j];
						arr[j] = arr[j+1];
						arr[j+1] = num;
					}
				}
			}
			return arr;
		}
		var arr = [];
		for(var i=0;i<30;i++){
			arr.push(Math.floor(Math.random(1,1000)*1000)+1);
		}
		document.write(paixu(arr));
	</script>
</head>
<body>
	
</body>
</html>